package main.java.反射;

/**
 * @Auther:Liu
 * @Testname:Test
 * @Date:2025/3/13 9:35
 */
public class Test {
    public static void main(String[] args) throws Exception {
        //获取Class对象
        String IP = "反射.Test01";
        Class<?> aClass = Class.forName(IP);

        //打印对象
        {
            System.out.println("_________法一___________");
            System.out.println(aClass);
            System.out.println(aClass.hashCode());
            System.out.println("__________法二__________");
            Test01 test01 = new Test01();
            Class<? extends Test01> aClass1 = test01.getClass();
            System.out.println(aClass1);
            System.out.println(aClass1.hashCode());
            System.out.println("___________法三________");
            System.out.println(Test01.class);
            System.out.println(Test01.class.hashCode());
            System.out.println("___________法四_________");
            ClassLoader classLoader = test01.getClass().getClassLoader();
            Class<?> aClass2 = classLoader.loadClass(IP);
            System.out.println(aClass2);
            System.out.println(aClass2.hashCode());
            System.out.println("____________________");
        }

        //打印对象信息
//        Test01 test = (Test01) aClass.newInstance();
//        System.out.println(test);

        //获取Class对象属性
//        Field[] fields = aClass.getFields();
//        for (Field f : fields
//        ) {
//            System.out.println(f.getName());
//        }

        //获取属性
//        Field name = aClass.getField("name1");
//        System.out.println(name);

        //获取文件名
//        System.out.println(aClass.getName());

        //基本数据类型
        //Integer
        Class<Integer> integerClass = int.class;
        System.out.println(integerClass);
        //char
        System.out.println(char.class);
        //boolean
        System.out.println(boolean.class);


    }
}
